home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
X User Tools
/
X User Tools (O'Reilly and Associates)(1994).ISO
/
sun4c
/
archive
/
tcltk.z
/
tcltk
/
man
/
cat3
/
3DBorder.3
next >
Wrap
Text File
|
1994-09-20
|
15KB
|
331 lines
Tk_Get3DBorder(3) Tk Library Procedures
_________________________________________________________________
NAME
Tk_Get3DBorder, Tk_Draw3DRectangle, Tk_Fill3DRectangle,
Tk_Draw3DPolygon, Tk_Fill3DPolygon,
Tk_SetBackgroundFromBorder, Tk_NameOf3DBorder,
Tk_Free3DBorder - draw borders with three-dimensional
appearance
SYNOPSIS
#include <tk.h>
Tk_3DBorder
Tk_Get3DBorder(_i_n_t_e_r_p, _t_k_w_i_n, _c_o_l_o_r_M_a_p, _c_o_l_o_r_N_a_m_e)
void
Tk_Draw3DRectangle(_d_i_s_p_l_a_y, _d_r_a_w_a_b_l_e, _b_o_r_d_e_r, _x, _y, _w_i_d_t_h, _h_e_i_g_h_t, _b_o_r_d_e_r_W_i_d_t_h, _r_e_l_i_e_f)
void
Tk_Fill3DRectangle(_d_i_s_p_l_a_y, _d_r_a_w_a_b_l_e, _b_o_r_d_e_r, _x, _y, _w_i_d_t_h, _h_e_i_g_h_t, _b_o_r_d_e_r_W_i_d_t_h, _r_e_l_i_e_f)
void
Tk_Draw3DPolygon(_d_i_s_p_l_a_y, _d_r_a_w_a_b_l_e, _b_o_r_d_e_r, _p_o_i_n_t_P_t_r, _n_u_m_P_o_i_n_t_s, _p_o_l_y_B_o_r_d_e_r_W_i_d_t_h, _l_e_f_t_R_e_l_i_e_f)
void
Tk_Fill3DPolygon(_d_i_s_p_l_a_y, _d_r_a_w_a_b_l_e, _b_o_r_d_e_r, _p_o_i_n_t_P_t_r, _n_u_m_P_o_i_n_t_s, _p_o_l_y_B_o_r_d_e_r_W_i_d_t_h, _l_e_f_t_R_e_l_i_e_f)
void
Tk_SetBackgroundFromBorder(_t_k_w_i_n, _b_o_r_d_e_r)
char *
Tk_NameOf3DBorder(_b_o_r_d_e_r)
XColor * |
Tk_3DBorderColor(_b_o_r_d_e_r) |
Tk_Free3DBorder(_b_o_r_d_e_r)
ARGUMENTS
Tcl_Interp *_i_n_t_e_r_p (in) Interpreter to use for
error reporting.
Tk_Window _t_k_w_i_n (in) Token for window in
which border will be
drawn.
Colormap _c_o_l_o_r_m_a_p (in) Colormap from which to
allocate colors. If
None, then the default
colormap for _t_k_w_i_n's
screen is used.
Tk 1
Tk_Get3DBorder(3) Tk Library Procedures
Tk_Uid _c_o_l_o_r_N_a_m_e (in) Textual description of
color corresponding to
background (flat
areas). Illuminated
edges will be brighter
than this, and sha-
dowed edges will be
darker than this.
Display *_d_i_s_p_l_a_y (in) Xlib pointer indicat-
ing display with which
drawable is associ-
ated.
Drawable _d_r_a_w_a_b_l_e (in) X token for window or
pixmap; indicates
where border is to be
drawn.
Tk_3DBorder _b_o_r_d_e_r (in) Token for border pre-
viously allocated in
call to
Tk_Get3DBorder.
int _x (in) X-coordinate of
upper-left corner of
rectangle describing
border.
int _y (in) Y-coordinate of
upper-left corner of
rectangle describing
border.
int _w_i_d_t_h (in) Width of rectangle
describing border, in
pixels.
int _h_e_i_g_h_t (in) Height of rectangle
describing border, in
pixels.
int _b_o_r_d_e_r_W_i_d_t_h (in) Width of border in
pixels. Positive means
border is inside rec-
tangle given by _x, _y,
_w_i_d_t_h, _h_e_i_g_h_t, nega-
tive means border is
outside rectangle.
int _r_e_l_i_e_f (in) Indicates 3-D position
of interior of
Tk 2
Tk_Get3DBorder(3) Tk Library Procedures
rectangle relative to
exterior; should be
TK_RELIEF_RAISED,
TK_RELIEF_SUNKEN,
TK_RELIEF_GROOVE, or |
TK_RELIEF_RIDGE (may |
also be TK_RELIEF_FLAT
for
Tk_Fill3DRectangle).
XPoint *_p_o_i_n_t_P_t_r (in) Pointer to array of
points describing the
set of vertices in a
polygon. The polygon
need not be closed (it
will be closed
automatically if it
isn't).
int _n_u_m_P_o_i_n_t_s (in) Number of points at
*_p_o_i_n_t_P_t_r.
int _p_o_l_y_B_o_r_d_e_r_W_i_d_t_h(in) Width of border in
pixels. If positive,
border is drawn to
left of trajectory
given by _p_o_i_n_t_P_t_r; if
negative, border is
drawn to right of tra-
jectory. If _l_e_f_t_R_e_-
_l_i_e_f is
TK_RELIEF_GROOVE or
TK_RELIEF_RIDGE then
the border is centered
on the trajectory.
int _l_e_f_t_R_e_l_i_e_f (in) Height of left side of
polygon's path rela-
tive to right.
TK_RELIEF_RAISED means
left side should
appear higher and
TK_RELIEF_SUNKEN means
right side should
appear higher; |
TK_RELIEF_GROOVE and |
TK_RELIEF_RIDGE mean |
the obvious things.
For Tk_Fill3DPolygon,
TK_RELIEF_FLAT may
also be specified to
indicate no difference
Tk 3
Tk_Get3DBorder(3) Tk Library Procedures
in height.
_________________________________________________________________
DESCRIPTION
These procedures provide facilities for drawing window bord-
ers in a way that produces a three-dimensional appearance.
Tk_Get3DBorder allocates colors and Pixmaps needed to draw a
border in the window given by the _t_k_w_i_n argument. The
_c_o_l_o_r_m_a_p argument specifies a Colormap to use for allocating
colors, and the _c_o_l_o_r_N_a_m_e argument indicates what colors
should be used in the border. _C_o_l_o_r_N_a_m_e may be any value
acceptable to Tk_GetColor. The color indicated by _c_o_l_o_r_N_a_m_e
will not actually be used in the border; it indicates the
background color for the window (i.e. a color for flat sur-
faces). The illuminated portions of the border will appear
brighter than indicated by _c_o_l_o_r_N_a_m_e, and the shadowed por-
tions of the border will appear darker than _c_o_l_o_r_N_a_m_e.
Tk_Get3DBorder returns a token that may be used in later
calls to Tk_Draw3DRectangle. If an error occurs in allocat-
ing information for the border (e.g. _c_o_l_o_r_N_a_m_e isn't a legal
color specifier), then NULL is returned and an error message
is left in _i_n_t_e_r_p->_r_e_s_u_l_t.
Once a border structure has been created, Tk_Draw3DRectangle
may be invoked to draw the border. The _d_i_s_p_l_a_y and _d_r_a_w_a_b_l_e
arguments specify a window or pixmap in which the border is
to be drawn. _D_r_a_w_a_b_l_e need not refer to the same window as
the _t_k_w_i_n used to create the border, but it must refer to a
compatible pixmap or window: one associated with the same
display and with the same depth as the _t_k_w_i_n used to create
the border. The _x, _y, _w_i_d_t_h, and _h_e_i_g_h_t arguments define
the bounding box of the border region within _d_r_a_w_a_b_l_e (usu-
ally _x and _y are zero and _w_i_d_t_h and _h_e_i_g_h_t are the dimen-
sions of the window), and _b_o_r_d_e_r_W_i_d_t_h specifies the number
of pixels actually occupied by the border. The _r_e_l_i_e_f argu-
ment indicates which of several three-dimensional effects is
desired: TK_RELIEF_RAISED means that the interior of the
rectangle should appear raised relative to the exterior of
the rectangle, and TK_RELIEF_SUNKEN means that the interior
should appear depressed. TK_RELIEF_GROOVE and |
TK_RELIEF_RIDGE mean that there should appear to be a groove |
or ridge around the exterior of the rectangle.
Tk_Fill3DRectangle is somewhat like Tk_Draw3DRectangle
except that it first fills the rectangular area with the
background color (one corresponding to the _c_o_l_o_r_N_a_m_e used to
create _b_o_r_d_e_r). Then it calls Tk_Draw3DRectangle to draw a
border just inside the outer edge of the rectangular area.
The argument _r_e_l_i_e_f indicates the desired effect
(TK_RELIEF_FLAT means no border should be drawn; all that
Tk 4
Tk_Get3DBorder(3) Tk Library Procedures
happens is to fill the rectangle with the background color).
The procedure Tk_Draw3DPolygon may be used to draw more com-
plex shapes with a three-dimensional appearance. The
_p_o_i_n_t_P_t_r and _n_u_m_P_o_i_n_t_s arguments define a trajectory,
_p_o_l_y_B_o_r_d_e_r_W_i_d_t_h indicates how wide the border should be (and
on which side of the trajectory to draw it), and _l_e_f_t_R_e_l_i_e_f
indicates which side of the trajectory should appear raised.
Tk_Draw3DPolygon draws a border around the given trajectory
using the colors from _b_o_r_d_e_r to produce a three-dimensional
appearance. If the trajectory is non-self-intersecting, the
appearance will be a raised or sunken polygon shape. The
trajectory may be self-intersecting, although it's not clear
how useful this is.
Tk_Fill3DPolygon is to Tk_Draw3DPolygon what
Tk_Fill3DRectangle is to Tk_Draw3DRectangle: it fills the
polygonal area with the background color from _b_o_r_d_e_r, then
calls Tk_Draw3DPolygon to draw a border around the area
(unless _l_e_f_t_R_e_l_i_e_f is TK_RELIEF_FLAT; in this case no
border is drawn).
The procedure Tk_SetBackgroundFromBorder will modify the
background pixel and/or pixmap of _t_k_w_i_n to produce a result
compatible with _b_o_r_d_e_r. For color displays, the resulting
background will just be the color given by the _c_o_l_o_r_N_a_m_e
argument passed to Tk_Get3DBorder when _b_o_r_d_e_r was created;
for monochrome displays, the resulting background will be a
light stipple pattern, in order to distinguish the back-
ground from the illuminated portion of the border.
Given a token for a border, the procedure Tk_NameOf3DBorder
will return the _c_o_l_o_r_N_a_m_e string that was passed to
Tk_Get3DBorder to create the border.
The procedure Tk_3DBorderColor returns the XColor structure |
that will be used for flat surfaces drawn for its _b_o_r_d_e_r |
argument by procedures like Tk_Fill3DRectangle. The return |
value corresponds to the _c_o_l_o_r_N_a_m_e passed to Tk_Get3DBorder. |
The XColor, and its associated pixel value, will remain |
allocated as long as _b_o_r_d_e_r exists.
When a border is no longer needed, Tk_Free3DBorder should be
called to release the resources associated with the border.
There should be exactly one call to Tk_Free3DBorder for each
call to Tk_Get3DBorder.
KEYWORDS
3D, background, border, color, depressed, illumination,
polygon, raised, shadow, three-dimensional effect
Tk 5